﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace JSON.App.Accelerator
{
    public class BaseEntity : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }

    public class Query : BaseEntity
    {
        private string _searchTerms;
        public string SearchTerms
        {
            get
            {
                return _searchTerms;
            }

            set
            {
                if (value != _searchTerms)
                {
                    _searchTerms = value;
                    NotifyPropertyChanged("SearchTerms");
                }
            }
        }
    }

    public class Result : BaseEntity
    {
        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }

        private string _url;
        public string Url
        {
            get { return _url; }
            set
            {
                if (value != _url)
                {
                    _url = value;
                    NotifyPropertyChanged("Url");
                }
            }
        }

        private string _business;
        public string Business
        {
            get { return _business; }
            set
            {
                if (value != _business)
                {
                    _business = value;
                    NotifyPropertyChanged("Business");
                }
            }
        }

        private string _phoneNumber;
        public string PhoneNumber
        {
            get { return _phoneNumber; }
            set
            {
                if (value != _phoneNumber)
                {
                    _phoneNumber = value;
                    NotifyPropertyChanged("PhoneNumber");
                }
            }
        }

        private string _address;
        public string Address
        {
            get { return _address; }
            set
            {
                if (value != _address)
                {
                    _address = value;
                    NotifyPropertyChanged("Address");
                }
            }
        }

        private string _city;
        public string City
        {
            get { return _city; }
            set
            {
                if (value != _city)
                {
                    _city = value;
                    NotifyPropertyChanged("City");
                }
            }
        }

        private string _stateOrProvince;
        public string StateOrProvince
        {
            get { return _stateOrProvince; }
            set
            {
                if (value != _stateOrProvince)
                {
                    _stateOrProvince = value;
                    NotifyPropertyChanged("StateOrProvince");
                }
            }
        }

        private string _countryOrRegion;
        public string CountryOrRegion
        {
            get { return _countryOrRegion; }
            set
            {
                if (value != _countryOrRegion)
                {
                    _countryOrRegion = value;
                    NotifyPropertyChanged("CountryOrRegion");
                }
            }
        }

        private string _postalCode;
        public string PostalCode
        {
            get { return _postalCode; }
            set
            {
                if (value != _postalCode)
                {
                    _postalCode = value;
                    NotifyPropertyChanged("PostalCode");
                }
            }
        }

        private double _latitude;
        public double Latitude
        {
            get { return _latitude; }
            set
            {
                if (value != _latitude)
                {
                    _latitude = value;
                    NotifyPropertyChanged("Latitude");
                }
            }
        }

        private double _longitude;
        public double Longitude
        {
            get { return _longitude; }
            set
            {
                if (value != _longitude)
                {
                    _longitude = value;
                    NotifyPropertyChanged("Longitude");
                }
            }
        }

        private string _uniqueId;
        public string UniqueId
        {
            get { return _uniqueId; }
            set
            {
                if (value != _uniqueId)
                {
                    _uniqueId = value;
                    NotifyPropertyChanged("UniqueId");
                }
            }
        }

        private string _displayUrl;
        public string DisplayUrl
        {
            get { return _displayUrl; }
            set
            {
                if (value != _displayUrl)
                {
                    _displayUrl = value;
                    NotifyPropertyChanged("DisplayUrl");
                }
            }
        }

        private double? _userRating;
        public double? UserRating
        {
            get { return _userRating; }
            set
            {
                if (value != _userRating)
                {
                    _userRating = value;
                    NotifyPropertyChanged("UserRating");
                }
            }
        }

        private int? _reviewCount;
        public int? ReviewCount
        {
            get { return _reviewCount; }
            set
            {
                if (value != _reviewCount)
                {
                    _reviewCount = value;
                    NotifyPropertyChanged("ReviewCount");
                }
            }
        }
    }

    public class Phonebook : BaseEntity
    {
        private int _total;
        public int Total
        {
            get { return _total; }
            set
            {
                if (value != _total)
                {
                    _total = value;
                    NotifyPropertyChanged("Total");
                }
            }
        }

        private int _offset;
        public int Offset
        {
            get { return _offset; }
            set
            {
                if (value != _offset)
                {
                    _offset = value;
                    NotifyPropertyChanged("Offset");
                }
            }
        }

        private string _localSerpUrl;
        public string LocalSerpUrl
        {
            get { return _localSerpUrl; }
            set
            {
                if (value != _localSerpUrl)
                {
                    _localSerpUrl = value;
                    NotifyPropertyChanged("LocalSerpUrl");
                }
            }
        }

        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }

        private ObservableCollection<Result> _results;
        public ObservableCollection<Result> Results
        {
            get { return _results; }
            set
            {
                if (value != _results)
                {
                    _results = value;
                    NotifyPropertyChanged("Results");
                }
            }
        }
    }

    public class SearchResponse : BaseEntity
    {
        private string _version;
        public string Version
        {
            get { return _version; }
            set
            {
                if (value != _version)
                {
                    _version = value;
                    NotifyPropertyChanged("Version");
                }
            }
        }

        private Query _query;
        public Query Query
        {
            get { return _query; }
            set
            {
                if (value != _query)
                {
                    _query = value;
                    NotifyPropertyChanged("Query");
                }
            }
        }

        private Phonebook _phonebook;
        public Phonebook Phonebook
        {
            get { return _phonebook; }
            set
            {
                if (value != _phonebook)
                {
                    _phonebook = value;
                    NotifyPropertyChanged("Phonebook");
                }
            }
        }
    }

    public class RootObject : BaseEntity
    {
        private SearchResponse _searchResponse;
        public SearchResponse SearchResponse
        {
            get { return _searchResponse; }
            set
            {
                if (value != _searchResponse)
                {
                    _searchResponse = value;
                    NotifyPropertyChanged("SearchResponse");
                }
            }
        }
    }
}